package com.ws.q1.mapper;

import com.ws.q1.bean.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {

 @Select("select * from qtyonghu where name=#{name} and pass=#{pass}")
 User login(@Param("name") String name, @Param("pass") String pass);

 @Insert("insert into qtyonghu(name,pass,phone,tou) values(#{name},#{pass},#{phone},#{tou})")
 int add(@Param("name") String name, @Param("pass") String pass, @Param("phone") String phone, @Param("tou") String tou);


 @Select("select * from qtyonghu where name=#{name}")
 Boolean isUsernameExists(String name);


 @Select("SELECT * FROM qtyonghu WHERE name LIKE CONCAT('%', #{name}, '%')")
 List<User> getUsersByName(@Param("name") String name);


 @Update("UPDATE qtyonghu SET name = #{user.name}, pass = #{user.pass}, phone = #{user.phone}, tou = #{user.tou} WHERE id = #{user.id}")
 void xiugai(@Param("user") User user);


 @Select("SELECT * FROM qtyonghu WHERE id = #{id}")
 User huixian(@Param("id") Integer id);
}
